cmake_minimum_required(VERSION 3.10)

project(classic_include_project)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) 
# 指定可执行文件输出目录, 比EXECUTABLE_OUTPUT_PATH优先级更高, 更新更好用
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
# 指定动态库输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
# 指定静态库输出目录
# EXECUTABLE_OUTPUT_PATH只能指定可执行文件的输出目录, 动态库和静态库需要另外的指定, 这在/ai/zhuxs/cpp_learn/cmake_tutorial/cmakeconf/building_output.cmake中也有体现

# 将src下的所有源文件放到SRC_LIST中用于构建动态库来调用
file(GLOB_RECURSE SRC_LIST ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
add_library(dynamic_lib 
SHARED
${SRC_LIST}
)
# 因为动态库源文件和头文件不在同一个目录, 一个在src一个在lib, 所以需要指定头文件路径
target_include_directories(dynamic_lib
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)

add_executable(classic_include_project main.cpp)

target_include_directories(classic_include_project
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(classic_include_project
PUBLIC
dynamic_lib
)